< previous page page_659 next page >

Page 659
e10a6a0a59f035e870d90cca05b85fce.gif
    m4Translate T2, 0, y, 0, W
    m4XZRotate r, theta / FRAMES_PER_FOLD
    m4MatMultiply T1R, T1, r
    m4MatMultiply All, T1R, T2

    For i = 1 To FRAMES_PER_FOLD
        If Not Running Then Exit Sub

        ' Rotate the cubes.
        For Each cube In col
            cube.Apply All
            cube.FixPoints
        Next cube

        ' Wait until it's time for the next image.
        WaitTill next_time
        next_time = GetTickCount + MS_PER_FRAME

        ' Display the picture.
        Draw picCanvas
    Next i
End Sub
Program Fold uses similar routines for rotating a cube around a plane parallel to the X-Y and Y-Z planes.
Most of the rotations used to fold up the hypercube are fairly easy to understand. In the second-to-last step, however, both of the two remaining cubes must be rotated together. Program Fold accomplishes this by placing both cubes in a collection, which it can then rotate as a single unit.
After the second-to-last cube is in position, the final cube has been rotated out of normal X-Y-Z coordinate space as shown in Figure 18.10. None of the points in this cube have W coordinates equal to zero. At this point, the corners of this cube with the smallest W coordinates are at locations (1, 1, 1, 2), (1, 1, 1, 2), (1, 1, 1, 2), and (1, 1, 1, 2). These points lie in the plane that is parallel to the Y-Z plane and has X = 1 and W = 2. To finish folding this last cube, the program uses subroutine FoldXW to rotate it around this plane.
z0679-01.gif
Figure 18.10
Before folding up the final cube.

 
< previous page page_659 next page >